﻿using System;
using System.Collections.Generic;
using System.Text;
using Cinema.Model;
using Cinema.c_dbDataSetTableAdapters;
using System.Threading;
using System.Data;

namespace Cinema.Control
{
    abstract class Administration
    {
        //context
        public static void addProjection(String startT, int price, String movieTitle, String saloonSignature)
        {
            Movie movie = null;
            Saloon saloon = null; 
            while (MainClass.updating)
            {
                Thread.Sleep(1000);
            }
            foreach(DataRow tempRow in MainClass.dataTableMovie.Rows)
            {
                if (tempRow[MainClass.dataTableMovie.Columns[MainClass.dataTableMovie.Columns.IndexOf("title")]].ToString().Equals(movieTitle)) 
                {
                    movie = new Movie(tempRow[MainClass.dataTableMovie.Columns.IndexOf("title")].ToString(), int.Parse(tempRow[MainClass.dataTableMovie.Columns.IndexOf("duration")].ToString()), int.Parse(tempRow[MainClass.dataTableMovie.Columns.IndexOf("year")].ToString()));
                    break;
                }
            }
            //DBsaloon.getBySignature(saloonSignature)
            foreach (DataRow tempRow in MainClass.dataTableSaloon.Rows)
            {
                if (tempRow[MainClass.dataTableSaloon.Columns[MainClass.dataTableSaloon.Columns.IndexOf("saloonSigniture")]].ToString().Equals(saloonSignature))
                {
                    saloon = new Saloon(int.Parse(tempRow[MainClass.dataTableSaloon.Columns.IndexOf("seats")].ToString()), 8, tempRow[MainClass.dataTableSaloon.Columns.IndexOf("saloonSigniture")].ToString());
                    break;
                }
                Projection projection = new Projection(startT, price, movie, saloon);
                //DBprojection.register(projection);
            }
        }
        //context
        public static List<Projection> findProjections()
        {
            List<Projection> projections = new List<Projection>();
            
            //projections = dbProjection.getProjection(false);
            return projections;
        }
    }
}
